import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ObjCreate } from "../../common/ObjCreate";
import { SGuildPlayer } from "../../../../../Message/Game/SGuildPlayer";
import { PlayerOpRegister } from "../../common/menu/PlayerOpRegister";
import { PlayerMiniInfo } from "../../../model/PlayerMiniInfo";
import { EGuildPosition } from "../../../../../Message/Game/EGuildPosition";
import { ImagesConst } from "../../../resource/ImagesConst";
import { AvatarInfo } from "../../../resource/info/AvatarInfo";
import { AvatarType } from "../../../resource/info/AvatarType";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { FilterConst } from "../../../../component/gconst/FilterConst";
//class ChatGuildMemberCellRenderer
    
    export  class ChatGuildMemberCellRenderer extends CellRenderer
    {
        constructor()
        {
            super();
            this.initStyles();
            this.create();
            return;
        }

        /* internal  */initStyles(): void
        {
            this.setStyle("downSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("overSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("selectedOverSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("selectedUpSkin", GlobalClass.getBitmap("Friend_over"));
            return;
        }

        /* internal  */create(): void
        {
            this._bmpPost = new Object /* flash.display.Bitmap */();
            this._bmpHeadImage = new Object /* flash.display.Bitmap */();
            this._bmpHeadImage.width = 20;
            this._bmpHeadImage.height = 20;
            this._bmpHeadImage.x = 22;
            this.addChild(this._bmpHeadImage);
            this._tfPlayerName = ObjCreate.createTextField("", 47, 2, 75, 20, this);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = data;
            if (typeof arg1 === "sguildplayer") 
            {
                this._guildPlayer = arg1 as SGuildPlayer;
                PlayerOpRegister.Register(this, new PlayerMiniInfo(this._guildPlayer.miniPlayer));
                this.reset();
            }
            return;
        }

        /* internal  */reset(): void
        {
            var imgName: string;

            var loc1;
            var loc2=this._guildPlayer.position;
            switch (loc2) 
            {
                case EGuildPosition._EGuildLeader:
                {
                    this._bmpPost.x = 1;
                    this._bmpPost.y = 0;
                    this._bmpPost.bitmapData = GlobalClass.getBitmapData(ImagesConst.ChatGuildMember_sun);
                    this._bmpPost.width = 20;
                    this._bmpPost.height = 20;
                    break;
                }
                case EGuildPosition._EGuildDeputyLeader:
                {
                    this._bmpPost.bitmapData = GlobalClass.getBitmapData(ImagesConst.ChatGuildMember_moon);
                    this._bmpPost.x = 1;
                    this._bmpPost.y = 0;
                    this._bmpPost.width = 20;
                    this._bmpPost.height = 20;
                    break;
                }
                case EGuildPosition._EGuildPresbyter:
                {
                    this._bmpPost.x = 1;
                    this._bmpPost.y = 0;
                    this._bmpPost.width = 20;
                    this._bmpPost.height = 20;
                    this._bmpPost.bitmapData = GlobalClass.getBitmapData(ImagesConst.ChatGuildMember_star);
                    break;
                }
                case EGuildPosition._EGuildMember:
                {
                    this._bmpPost.bitmapData = null;
                    break;
                }
                default:
                {
                    this._bmpPost.bitmapData = null;
                    break;
                }
            }
            this.addChild(this._bmpPost);
            imgName = AvatarInfo.getPlayerAvatarName(this._guildPlayer.miniPlayer.camp, this._guildPlayer.miniPlayer.sex, AvatarType.FRIEND, this._guildPlayer.miniPlayer.avatarId);
            with ({}) 
            {
            };
            imgName.load(
#error('pushwith') {}
            , 
#error('pushwith') {}
            .onAvatarLoaded = (arg1: ImageInfo): void
            {
                _bmpHeadImage.bitmapData = arg1.bitmapData;
                _bmpHeadImage.width = 20;
                _bmpHeadImage.height = 20;
                return;
            })
            this._tfPlayerName.text = this._guildPlayer.miniPlayer.name;
            if (this._guildPlayer.miniPlayer.online) 
            {
                this._bmpHeadImage.filters = [];
                loc2 = this._guildPlayer.miniPlayer.VIP;
                switch (loc2) 
                {
                    case 9:
                    {
                        this._tfPlayerName.setTextFormat(GlobalStyle.textFormatVIP3);
                        this._tfPlayerName.filters = [FilterConst.vipGlowFilter];
                        break;
                    }
                    case 6:
                    {
                        this._tfPlayerName.setTextFormat(GlobalStyle.textFormatVIP2);
                        this._tfPlayerName.filters = [FilterConst.vipGlowFilter];
                        break;
                    }
                    case 3:
                    {
                        this._tfPlayerName.setTextFormat(GlobalStyle.textFormatVIP1);
                        this._tfPlayerName.filters = [FilterConst.vipGlowFilter];
                        break;
                    }
                    default:
                    {
                        this._tfPlayerName.setTextFormat(GlobalStyle.textFormatOnLine);
                        this._tfPlayerName.filters = [FilterConst.nameGlowFilter];
                    }
                }
            }
            else 
            {
                this._tfPlayerName.setTextFormat(GlobalStyle.textFormatOffline);
                this._bmpHeadImage.filters = [FilterConst.colorFilter];
                this._tfPlayerName.filters = [FilterConst.nameGlowFilter];
            }
            return;
        }

        /* internal */ /* var */_bmpPost: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bmpHeadImage: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfPlayerName: Object /* flash.text.TextField */;

        /* internal */ /* var */_guildPlayer: SGuildPlayer;
    }
